let hd = `
https://hdcms.com
http://www.sina.com.cn
https://www.houdunrne.com
`;

let reg = /https?:\/\/(\w+\.)?(\w+\.)+(com|cn|org|cc)/gi;
// 这里可以将 (\w+\.)分成两个组，这样就可以匹配到两个域名

console.dir(hd.match(reg));

let str = "PERSIHMANCE";
console.log(str.match("CE")); //也可以写正则
console.log(str.search("P")); // 返回的是匹配到的下标

for (const iterator of hd.matchAll(reg)) {
  console.log(iterator);
}

let hd1 = "2020/09/12";
console.log(hd1.split(/[-\/]/));

let hd2 = "(010)99999999 (020)88888888";
let reg1 = /\((\d{3,4})\)(\d{7,8})/g;
console.log(hd2.match(reg1));
console.log(hd2.replace(reg1, "$1-$2")); // $1表示010 $2表示020
